# _*_ coding: UTF-8 _*_
# 开发人员  ：LuoWen_Top
# 开发时间  ：2020/10/29 13:53
# 文件名称  ：urls.py
# 开发工具  ：PyCharm


"""
    开发该文档说明。
"""
from django.conf.urls import url

# from .views import snippet_list, snippet_detail
# from .views import SnippetList, SnippetDetail, SnippetHighlight, UserList, UserDetail
from .views import SnippetViewSet, UserSnippetViewSet
from rest_framework import renderers

snippet_list = SnippetViewSet.as_view({
    'get': 'list',
    'post': 'create'
})
snippet_detail = SnippetViewSet.as_view({
    'get': 'retrieve',
    'put': 'update',
    'patch': 'partial_update',
    'delete': 'destroy'
})
snippet_highlight = SnippetViewSet.as_view({
    'get': 'highlight'
}, renderer_classes=[renderers.StaticHTMLRenderer])
user_list = UserSnippetViewSet.as_view({
    'get': 'list'
})
user_detail = UserSnippetViewSet.as_view({
    'get': 'retrieve'
})

urlpatterns = [
    # url(r'^$', snippet_list),
    # url(r'^(?P<pk>[0-9]+)/$', snippet_detail),

    # url(r'^$', SnippetList.as_view(), name='snippet-list'),
    # url(r'^(?P<pk>[0-9]+)/$', SnippetDetail.as_view(), name='snippet-detail'),
    # url(r'^(?P<pk>[0-9]+)/highlight/$', SnippetHighlight.as_view(), name='snippet-highlight'),
    #
    # url(r'^users/$', UserList.as_view(), name='user-list'),
    # url(r'^users/(?P<pk>[0-9]+)/$', UserDetail.as_view(), name='user-detail'),

    # 使用viewset
    url(r'^$', snippet_list, name='snippet-list'),
    url(r'^(?P<pk>[0-9]+)/$', snippet_detail, name='snippet-detail'),
    url(r'^(?P<pk>[0-9]+)/highlight/$', snippet_highlight, name='snippet-highlight'),

    url(r'^users/$', user_list, name='user-list'),
    url(r'^users/(?P<pk>[0-9]+)/$', user_detail, name='user-detail'),

]
